🤖 Extract Invoice
Introduction​
This API allows users to send an invoice via a POST request, and n8n will automatically evaluate and rate the invoice. The API processes the content and returns an analysis based on the provided model.
Extract Invoice​
Endpoint​
Use the following endpoint to submit the invoice for analytic:
POST https://n8n.lchatai.com/execute/invoice-analytics
Headers​
The API requires the following headers:
X-N8N-API-KEY- Your n8n API key for authenticationContent-Type: multipart/form-data
Request Parameters​
The API expects the following parameters as multipart/form-data fields:
-
model(string) - The AI model to use. Accepted values:Provider Models OpenAI gpt-4o,gpt-4o-mini,gpt-4-turbo,gpt-3.5-turbo,gpt-4.1,gpt-4.1-mini,gpt-4.1-nano,gpt-5.2,gpt-5.2-pro,gpt-5,gpt-5-mini,gpt-5-nanoGemini gemini-2.5-flash,gemini-2.5-pro,gemini-2.5-flash-lite,gemini-3-flash-preview,gemini-3.1-pro-previewClaude claude-sonnet-4-6,claude-opus-4-6,claude-opus-4-5-20251101,claude-haiku-4-5-20251001,claude-sonnet-4-5-20250929,claude-opus-4-1-20250805,claude-opus-4-20250514,claude-sonnet-4-20250514 -
prompt(string) - The specific prompt to provide for the invoice evaluation. -
llmKey(string) - Your API key for the selected model. -
content(string) - The invoice text to be analyzed. Use this field when submitting plain text. Leave empty ("") when uploading a file via thefilefield. -
file(file) - A PDF or document file containing the invoice. Use this field when submitting a file. Leave empty ("") when using thecontentfield.
Exactly one of content or file must be provided per request. If you are sending text, pass file="". If you are uploading a file, pass content="".
Example Request​
- Bash
- Javascript
- Python
- Php
Text Content
curl --location 'https://n8n.lchatai.com/execute/invoice-analytics' \
--header 'X-N8N-API-KEY: ey*********' \
--form 'model="gpt-4o-mini"' \
--form 'prompt="..."' \
--form 'content="Invoice text content here..."' \
--form 'llmKey="sk-proj-ERa23*******"' \
--form 'file=""'
File Upload
curl --location 'https://n8n.lchatai.com/execute/invoice-analytics' \
--header 'X-N8N-API-KEY: ey*********' \
--form 'model="gpt-4o-mini"' \
--form 'prompt="..."' \
--form 'content=""' \
--form 'llmKey="sk-proj-ERa23*******"' \
--form 'file=@"/path/to/invoice.pdf"'
Text Content
// Text Content mode
const formData = new FormData();
formData.append('model', 'gpt-4o-mini');
formData.append('prompt', '...');
formData.append('content', 'Invoice text content here...');
formData.append('llmKey', 'sk-proj-ERa23*******');
formData.append('file', '');
fetch('https://n8n.lchatai.com/execute/invoice-analytics', {
method: 'POST',
headers: { 'X-N8N-API-KEY': 'ey*********' },
body: formData
})
.then(response => response.json())
.then(data => console.log(data));
File Upload
// File Upload mode
const formData = new FormData();
formData.append('model', 'gpt-4o-mini');
formData.append('prompt', '...');
formData.append('content', '');
formData.append('llmKey', 'sk-proj-ERa23*******');
formData.append('file', fileInput.files[0]); // File object from <input type="file">
fetch('https://n8n.lchatai.com/execute/invoice-analytics', {
method: 'POST',
headers: { 'X-N8N-API-KEY': 'ey*********' },
body: formData
})
.then(response => response.json())
.then(data => console.log(data));
Text Content
import requests
url = "https://n8n.lchatai.com/execute/invoice-analytics"
headers = { "X-N8N-API-KEY": "ey*********" }
# Text Content mode
data = {
"model": "gpt-4o-mini",
"prompt": "...",
"content": "Invoice text content here...",
"llmKey": "sk-proj-ERa23*******",
"file": ""
}
response = requests.post(url, headers=headers, data=data)
print(response.json())
File Upload
import requests
url = "https://n8n.lchatai.com/execute/invoice-analytics"
headers = { "X-N8N-API-KEY": "ey*********" }
# File Upload mode
data = {
"model": "gpt-4o-mini",
"prompt": "...",
"content": "",
"llmKey": "sk-proj-ERa23*******"
}
files = { "file": open("/path/to/invoice.pdf", "rb") }
response = requests.post(url, headers=headers, data=data, files=files)
print(response.json())
Text Content
<?php
// Text Content mode
$url = "https://n8n.lchatai.com/execute/invoice-analytics";
$headers = ["X-N8N-API-KEY: ey*********"];
$data = [
"model" => "gpt-4o-mini",
"prompt" => "...",
"content" => "Invoice text content here...",
"llmKey" => "sk-proj-ERa23*******",
"file" => ""
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);
curl_close($ch);
?>
File Upload
<?php
// File Upload mode
$url = "https://n8n.lchatai.com/execute/invoice-analytics";
$headers = ["X-N8N-API-KEY: ey*********"];
$data = [
"model" => "gpt-4o-mini",
"prompt" => "...",
"content" => "",
"llmKey" => "sk-proj-ERa23*******",
"file" => new CURLFile("/path/to/invoice.pdf")
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);
curl_close($ch);
?>
Response​
The response body contains the following two keys:
response(string): The result of the invoice analysis, which provides the evaluation and rating of the submitted invoice.execution_id(integer): A unique identifier for the specific execution of the invoice analytics workflow.
{
"response": ".....",
"execution_id": 778
}